{include file="public/header" /}

<body>
    <div class="layui-card-body">
        <form class="layui-form" action="" lay-filter="component-form-element">
            <div class="layui-fluid">
                <div class="layui-row layui-col-space15">
                    <div class="layui-col-md12">
                        <div class="layui-card">
                            <div class="layui-card-header">基础信息</div>
                            <div class="layui-card-body layui-row layui-col-space10">
                                <div class="layui-col-md4">
                                    <label class="layui-form-label">客户姓名:</label>
                                    <div class="layui-input-block">
                                        <select name="user_id" lay-filter="user_id" lay-search="search" lay-verify="required">
                                            <option value="">请选择客户账号</option>
                                            {foreach $user as $v}
                                            <option value="{$v.id}" {if !empty($row.user_id) &&
                                                $row.user_id==$v.id}selected{/if}>{:config('config.cangku')[$v.type]}/{$v.name|default=''}({$v.mobile|default=''})</option>
                                            {/foreach}
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-col-md4">
                                    <label class="layui-form-label">订单类型:</label>
                                    <div class="layui-input-block">
                                        <select name="type" lay-verify="required">
                                            <option value="">订单类型</option>
                                            {foreach $types as $k => $v}
                                            <option value="{$k}" {if !empty($row.type) && $row.type==$k}selected{/if}>
                                                {$v}</option>
                                            {/foreach}
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-col-md4">
                                    <label class="layui-form-label">收款日期:</label>
                                    <div class="layui-input-block">
                                        <input type="text" id="test" name="times" required="" lay-verify="required"
                                            autocomplete="off" class="layui-input" value="{$row.times|default=''}"
                                            placeholder="">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-card">
                            <div class="layui-card-header">订单金额信息</div>
                            <div class="layui-card-body layui-row layui-col-space10">
                                <div class="layui-col-md4">
                                    <label class="layui-form-label">实收款(元):</label>
                                    <div class="layui-input-block">
                                        <input type="number" name="apayment" required="" lay-verify="required"
                                            autocomplete="off" class="layui-input" value="{$row.apayment|default='0'}"
                                            placeholder="">
                                    </div>
                                </div>
                                <div class="layui-col-md4">
                                    <label class="layui-form-label">补贴(元):</label>
                                    <div class="layui-input-block">
                                        <input type="number" name="subsidy" required="" lay-verify="required"
                                            autocomplete="off" class="layui-input" value="{$row.subsidy|default='0'}"
                                            placeholder="">
                                    </div>
                                </div>
                                <div class="layui-col-md4">
                                    <label class="layui-form-label">退换(元):</label>
                                    <div class="layui-input-block">
                                        <input type="number" name="refunds" required="" lay-verify="required"
                                            autocomplete="off" class="layui-input" value="{$row.refunds|default='0'}"
                                            placeholder="">
                                    </div>
                                </div>
                                <div class="layui-col-md4">
                                    <label class="layui-form-label">物料(元):</label>
                                    <div class="layui-input-block">
                                        <input type="number" name="materials" required="" lay-verify="required"
                                            autocomplete="off" class="layui-input" value="{$row.materials|default='0'}"
                                            placeholder="">
                                    </div>
                                </div>
                                <div class="layui-col-md4">
                                    <label class="layui-form-label">返点(元):</label>
                                    <div class="layui-input-block">
                                        <input type="number" name="rebate" required="" lay-verify="required"
                                            autocomplete="off" class="layui-input" value="{$row.rebate|default='0'}"
                                            placeholder="">
                                    </div>
                                </div>
                                <div class="layui-col-md4">
                                    <label class="layui-form-label">结余(元):</label>
                                    <div class="layui-input-block">
                                        <input type="number" name="balance" required="" lay-verify="required"
                                            autocomplete="off" class="layui-input" value="{$row.balance|default='0'}"
                                            placeholder="">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-card">
                            <div class="layui-card-header">订单及付款信息</div>
                            <div class="layui-card-body layui-row layui-col-space10">
                                <div class="layui-col-md4">
                                    <label class="layui-form-label">订单状态:</label>
                                    <div class="layui-input-block">
                                        <select name="status" lay-verify="required">
                                            <option value="">请选择订单状态</option>
                                            {foreach $statuss as $k => $v}
                                            <option value="{$k}" {if !empty($row.status) &&
                                                $row.status==$k}selected{/if}>
                                                {$v}</option>
                                            {/foreach}
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-col-md4">
                                    <label class="layui-form-label">是否付款:</label>
                                    <div class="layui-input-block">
                                        {foreach $paystatuss as $k => $v}
                                        <input type="radio" name="paystatus" value="{$k}" title="{$v}" {if
                                            !empty($row.paystatus) && $row.paystatus==$k}checked{/if} {if
                                                empty($row.paystatus) && $k==1}checked{/if}>
                                        {/foreach}
                                    </div>
                                </div>
                                <div class="layui-col-md4">
                                    <label class="layui-form-label">付款方式:</label>
                                    <div class="layui-input-block">
                                        <select name="payment" lay-verify="">
                                            <option value="">请选择付款方式</option>
                                            {foreach $payments as $k => $v}
                                            <option value="{$k}" {if !empty($row.payment) &&
                                                $row.payment==$k}selected{/if}>
                                                {$v}</option>
                                            {/foreach}
                                        </select>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-card">
                            <div class="layui-card-header">备注信息:</div>
                            <div class="layui-card-body layui-row layui-col-space10">
                                <textarea name="remark" placeholder=""
                                    class="layui-textarea">{$row.remark|default=''}</textarea>
                            </div>
                        </div>
                        <div class="layui-card">
                            <div class="layui-card-header">经办人:</div>
                            <div class="layui-card-body layui-row layui-col-space10">
                                <input type="text" name="jsr" required="required" lay-verify="required" autocomplete="off"
                                    class="layui-input" value="{$row.jsr|default=''}" placeholder="">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <input type="hidden" value="{$row['id']|default='0'}" name="id" />
                    <button class="layui-btn" lay-submit="" lay-filter="add">提交</button>
                    <!-- <button type="reset" class="layui-btn layui-btn-primary">重置</button> -->
                </div>
            </div>
        </form>
    </div>
    {include file="public/footer" /}
    <!-- <script src="/static/leyedit/Layui-KnifeZ/layui.all.js"></script>
    <script src="/static/leyedit/ace/ace.js"></script> -->
    <script>
        layui.extend({
            // 加载自定义模块
            layarea: '{/}/layuiadmin/modules/layarea',
        }).use(['layer', 'jquery', 'form', 'laydate', 'layarea'], function () {
            $ = layui.jquery;
            var form = layui.form
                , laydate = layui.laydate,
                layarea = layui.layarea
                , layer = layui.layer;
            layarea.render({
                elem: '#area-picker',
                change: function (res) {
                    console.log(11);
                    //选择结果
                }
            });
            laydate.render({
                elem: '#test'
                , type: 'date'
            });
            //监听提交
            form.on('submit(add)', function (data) {
                $.ajax({
                    'type': 'post',
                    data: data.field,
                    success: function (res) {
                        if (res.code == 0) {
                            layer.msg(res.msg, { icon: 6, time: 1000 }, function () {
                                // 获得frame索引
                                var index = parent.layer.getFrameIndex(window.name);
                                parent.location.reload();
                                parent.layer.close(index);
                            });
                        } else {
                            layer.msg(res.msg, { icon: 2, time: 1000 });
                        }
                    }
                });
                return false;
            });
        });
    </script>

</body>

</html>